FROM debian:bullseye

RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list \
    && apt update \
    && apt install -y curl openssl socat \
    && groupadd -g 1000 acmesh \
    && useradd -u 1000 -g 1000 -c "Atompi acmesh user" -d /home/acmesh -m -s "/bin/bash" acmesh

COPY proxy /usr/bin/proxy

USER acmesh
WORKDIR /home/acmesh

ARG MY_EMAIL
RUN proxy curl https://get.acme.sh | proxy bash -s email=${MY_EMAIL} --force \
    && cd /home/acmesh/.acme.sh \
    && ./acme.sh --upgrade --auto-upgrade 0 \
    && ./acme.sh --uninstall-cronjob

WORKDIR /home/acmesh/.acme.sh
